package com.wenresearch.orion.components.ui.accordion;

import java.util.Vector;

import net.rim.device.api.ui.container.VerticalFieldManager;

/**
 * Accordion panel manage multiple accordion content
 * <code>
 * UiAccordionPanel panel = new UiAccordionPanel();
 * ...
 * UiAccordion acc = new UiAccordion("Item 1", new VerticalFieldManager());
 * panel.add(acc);
 * ...
 * </code>
 * @author Ali Irawan (boylevantz@gmail.com)
 *
 */
public class UiAccordionPanel extends VerticalFieldManager {

	private Vector _items = new Vector();
	
	/**
	 * Create a new accordion panel
	 * 
	 */
	public UiAccordionPanel(){
		super(FOCUSABLE);
	}
	
	/**
	 * Get accordion count in this panel
	 * 
	 * @return count of accordions in this panel
	 */
	public int size(){
		return _items.size();
	}
	
	/**
	 * Add more accordion to this panel
	 * @param item accordion item
	 */
	public void add(UiAccordion item){
		_items.addElement(item);
		super.add(item);
	}
	
	/**
	 * Remove accordion by object
	 * @param item item to be removed from panel
	 */
	public void remove(UiAccordion item){
		_items.removeElement(item);
		super.delete(item);
	}
	
	/**
	 * Remove accordion in specified index
	 * @param index index that accordion to be removed
	 */
	public void removeAt(int index){
		_items.removeElementAt(index);
		super.deleteRange(index, 1);
	}
	
	/**
	 * Get accordion by index
	 * @param index index start from 0 for the first item
	 * @return an accordion in specified index
	 */
	public UiAccordion get(int index){
		return (UiAccordion) _items.elementAt(index);
	}
}
